<?php if ($this->_var['full_page']): ?>
<?php echo $this->fetch('pageheader.htm'); ?>
<?php echo $this->smarty_insert_scripts(array('files'=>'../js/utils.js,listtable.js,jquery-1.7.2.min.js')); ?>
<script type="text/javascript" src="../js/calendar.php?lang=<?php echo $this->_var['cfg_lang']; ?>"></script>
<link href="../js/calendar/calendar.css" rel="stylesheet" type="text/css" />
<style>
			#tooltip{
				position:absolute;
				border:1px solid #ccc;
				background:#333;
				padding:2px;
				display:none;
				color:#fff;
			}
</style>
<!-- 商品搜索 -->
<div class="form-div">
  <form action="javascript:searchNews()" name="searchForm" >
    <img src="images/icon_search.gif" width="26" height="22" border="0" alt="SEARCH" />
	
	<?php echo $this->_var['lang']['create_time']; ?>
	<input name="start_time" onclick="return showCalendar('start_time', '%Y-%m-%d %H:%M', '24', false, 'start_time');" type="text" id="start_time" size="22" value='<?php echo $this->_var['start_time']; ?>' readonly="readonly" />
	<?php echo $this->_var['lang']['zhi']; ?>
	<input name="end_time" onclick="return showCalendar('end_time', '%Y-%m-%d %H:%M', '24', false, 'end_time');" type="text" id="end_time" size="22" value='<?php echo $this->_var['end_time']; ?>' readonly="readonly" />
    
	<br/>
	<br/>
	<?php echo $this->_var['lang']['circle_name']; ?> 
	<select name="circle_id">
		<option value="">--- ---</option>
		<?php $_from = $this->_var['circle_select']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'circle');if (count($_from)):
    foreach ($_from AS $this->_var['circle']):
?>
			<option value="<?php echo $this->_var['circle']['id']; ?>"><?php echo $this->_var['circle']['circle_name']; ?></option>
		<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?> 
	</select>
	<?php echo $this->_var['lang']['audit_status']; ?>
	<select name="audit_status">
		<option value="">-- --</option>
		<option value="1">未审核</option>
		<option value="2">审核通过</option>
		<option value="3">审核不通过</option>
	</select>
	<?php echo $this->_var['lang']['creater']; ?>
	<input name="creater" type="text" id="creater" size="22" value='<?php echo $this->_var['creater']; ?>'/>
	
    <input type="submit" value="<?php echo $this->_var['lang']['button_search']; ?>" class="button" />
  </form>
</div>
<!-- 商品列表 -->
<form method="post" action="" name="listForm" onsubmit="return confirmSubmit(this)">
  <!-- start goods list -->
  <div class="list-div" id="listDiv">
<?php endif; ?>
<table cellpadding="3" cellspacing="1">
  <tr>
    <!--<th>
      <input onclick='listTable.selectAll(this, "checkboxes")' type="checkbox" />
      <a href="javascript:listTable.sort('id'); "><?php echo $this->_var['lang']['record_id']; ?></a><?php echo $this->_var['sort_id']; ?>
    </th>-->
    <th><?php echo $this->_var['lang']['title']; ?></th>
    <th><?php echo $this->_var['lang']['circle_name']; ?></th>
    <th><?php echo $this->_var['lang']['creater']; ?></th>
    <th ><?php echo $this->_var['lang']['content']; ?></th>
    <th><?php echo $this->_var['lang']['news_img']; ?></th>
    <th><a href="javascript:listTable.sort('create_time'); "><?php echo $this->_var['lang']['create_time']; ?></a><?php echo $this->_var['sort_create_time']; ?></th>
    <th><?php echo $this->_var['lang']['audit_status']; ?></th>
    <th><?php echo $this->_var['lang']['is_top']; ?></th>
    <th><?php echo $this->_var['lang']['sort_order']; ?></th>
    <th><?php echo $this->_var['lang']['handler']; ?></th>
  <tr>
  <?php $_from = $this->_var['news_list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'news');if (count($_from)):
    foreach ($_from AS $this->_var['news']):
?>
  <tr>
    <!--<td align="left"><input type="checkbox" name="checkboxes[]" value="<?php echo $this->_var['circle']['id']; ?>" /><?php echo $this->_var['circle']['id']; ?></td>-->
    <td class="first-cell">
    	<span onclick="javascript:listTable.edit(this, 'edit_title', <?php echo $this->_var['news']['id']; ?>)"><?php echo empty($this->_var['news']['title']) ? '暂无' : $this->_var['news']['title']; ?></span>
    	
	</td>
    <td >
    	<select name="circle_id" onChange="changeCircle(this,<?php echo $this->_var['news']['id']; ?>)">
			<option value="" >---</option>
			<?php $_from = $this->_var['circle_select']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'circle');if (count($_from)):
    foreach ($_from AS $this->_var['circle']):
?>
				<option value="<?php echo $this->_var['circle']['id']; ?>"  <?php if ($this->_var['news']['circle_id'] == $this->_var['circle']['id']): ?>selected="selected"<?php endif; ?> ><?php echo $this->_var['circle']['circle_name']; ?></option>
			<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?> 
		</select>
	</td>
	<td align="center"><?php echo $this->_var['news']['nickname']; ?></td>
    <td  style="max-width:100px" align="left"><?php echo $this->_var['news']['content']; ?></td>
	<td align="center">
		<?php $_from = $this->_var['news']['img']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'pic');if (count($_from)):
    foreach ($_from AS $this->_var['pic']):
?>
			<a href="/chunle<?php echo $this->_var['pic']['thumb']; ?>" class="tooltip" ><img src="/chunle<?php echo $this->_var['pic']['thumb']; ?>"  style="width:30px;"></a>
		<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
		
	</td>
    <td align="center"><?php echo $this->_var['news']['create_time']; ?></td>
	<td align="center"><?php echo $this->_var['news']['audit_status_show']; ?></td>
	<td align="center"><img src="images/<?php if ($this->_var['news']['is_top']): ?>yes<?php else: ?>no<?php endif; ?>.gif" onclick="listTable.toggle(this, 'toggle_is_top', <?php echo $this->_var['news']['id']; ?>)" /></td>
	<td class="center">
    	<span onclick="javascript:listTable.edit(this, 'edit_order', <?php echo $this->_var['news']['id']; ?>)"><?php echo empty($this->_var['news']['sort_order']) ? '0' : $this->_var['news']['sort_order']; ?></span>
    	
	</td>
    <td align="center">
      <?php if ($this->_var['news']['audit_status'] == '1'): ?>
      <a onClick="audit(<?php echo $this->_var['news']['id']; ?>,2)" href="javascript:;" ><?php echo $this->_var['lang']['audit_pass']; ?></a>|
      <a onClick="audit(<?php echo $this->_var['news']['id']; ?>,3)" href="javascript:;" ><?php echo $this->_var['lang']['audit_nopass']; ?></a>
	  <?php elseif ($this->_var['news']['audit_status'] == '2'): ?>
      <a onClick="audit(<?php echo $this->_var['news']['id']; ?>,3)" href="javascript:;" ><?php echo $this->_var['lang']['audit_nopass']; ?></a>
	  <?php elseif ($this->_var['news']['audit_status'] == '3'): ?>
      <a onClick="audit(<?php echo $this->_var['news']['id']; ?>,2)" href="javascript:;" ><?php echo $this->_var['lang']['audit_pass']; ?></a>
      <?php endif; ?>
	  |
      <a href="javascript:;" onclick="listTable.remove(<?php echo $this->_var['news']['id']; ?>, '<?php echo $this->_var['lang']['drop_confirm']; ?>')" title="<?php echo $this->_var['lang']['remove']; ?>"><?php echo $this->_var['lang']['remove']; ?></a>
	  |
      <a href="news_comment.php?act=list&amp;news_id=<?php echo $this->_var['news']['id']; ?>" ><?php echo $this->_var['lang']['comment']; ?></a>
    </td>
  </tr>
  <?php endforeach; else: ?>
  <tr><td class="no-records" colspan="10"><?php echo $this->_var['lang']['no_records']; ?></td></tr>
  <?php endif; unset($_from); ?><?php $this->pop_vars();; ?>
</table>
<!-- end goods list -->
<!-- 分页 -->
<table id="page-table" cellspacing="0">
  <tr>
    <td align="right" nowrap="true">
    <?php echo $this->fetch('page.htm'); ?>
    </td>
  </tr>
</table>
<?php if ($this->_var['full_page']): ?>
</div>
</form>
<script>
	listTable.recordCount = <?php echo $this->_var['record_count']; ?>;
	listTable.pageCount = <?php echo $this->_var['page_count']; ?>;
	
	<?php $_from = $this->_var['filter']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('key', 'item');if (count($_from)):
    foreach ($_from AS $this->_var['key'] => $this->_var['item']):
?>
	listTable.filter.<?php echo $this->_var['key']; ?> = '<?php echo $this->_var['item']; ?>';
	<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
/* 搜索文章 */
 function searchNews()
 {
    listTable.filter.circle_id = Utils.trim(document.forms['searchForm'].elements['circle_id'].value);
    listTable.filter.audit_status = Utils.trim(document.forms['searchForm'].elements['audit_status'].value);
    listTable.filter.start_time = Utils.trim(document.forms['searchForm'].elements['start_time'].value);
    listTable.filter.end_time = Utils.trim(document.forms['searchForm'].elements['end_time'].value);
    listTable.filter.creater = Utils.trim(document.forms['searchForm'].elements['creater'].value);
    listTable.filter.page = 1;
    listTable.loadList();
	tool();
 }
 function audit(id,audit_status){
 	var url = "news.php?act=audit&id="+id+"&audit_status="+audit_status;
 	Ajax.call(url, "",function(result){
		if (result.error > 0)
		  {
		    alert(result.message);
		  }
		  else
		  {
		  	$(".button").eq(0).click();
		  }
	}, "GET", "JSON");
 }
 function tool(){
 	var x = 10;
	var y = 20;
	$("a.tooltip").mouseover(function(e){
		this.myTitle = this.title;
		this.title = "";
		var imgTitle = this.myTitle? "<br/>" + this.myTitle : "";
		var tooltip = "<div id='tooltip'><img style='max-width:250px;' src='"+ this.href +"' alt='产品预览图'/>"+imgTitle+"<\/div>"; //创建 div 元素
		$("body").append(tooltip);	//把它追加到文档中
//		$("#tooltip")
//			.css({
//				"top": (e.pageY+y) + "px",
//				"left":  (e.pageX+x)  + "px"
//			});
	document.getElementById("tooltip").style.top = (e.pageY+y) + "px";
	document.getElementById("tooltip").style.left = (e.pageX+x)  + "px";
	document.getElementById("tooltip").style.display = "block";
//		.show("fast");	  //设置x坐标和y坐标，并且显示
    }).mouseout(function(){
		this.title = this.myTitle;
		$("#tooltip").remove();	 //移除
    }).mousemove(function(e){
		document.getElementById("tooltip").style.top = (e.pageY+y) + "px";
		document.getElementById("tooltip").style.left = (e.pageX+x)  + "px";
	});
 }
 $(function(){
	tool();
})
function  callbackAjax(){
 	tool();
 }
 
 function changeCircle(params,id){
	var val=$(params).find("option:selected").val();
	var url = "news.php?act=editCircle";
	var data = {
		id:id,
		circle_id:val
	}
	res = Ajax.call(url, "id="+id+"&circle_id=" + val , null, "POST", "JSON", false);
	if (res.message)
    alert(res.message);
 }
</script>
<?php echo $this->fetch('pagefooter.htm'); ?>
<?php endif; ?>
